<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@Keyup.enter ----监听键盘回车事件</title>
  </head>
  <body>
    <div id="app">
      <h3>@Keyup.enter ----监听键盘回车事件</h3>
      <input @keyup.enter="fn" v-model="message" type="text" />
    </div>

    <script src="../js/vue.js"></script>
    <script>
      var app = new Vue({
        el: "#app",
        data: {
          message: "",
        },
        methods: {
          fn(e) {
            if (e.key === "Enter") {
              console.log("键盘回车的时候触发", this.message);
            }
          },
        },
      });
    </script>
  </body>
</html>
